package com.findFish.fish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.fish.domain.FishPopulation;
import com.findFish.fish.service.IFishPopulationService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 鱼群管理Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/fish/population")
public class FishPopulationController extends BaseController
{
    @Autowired
    private IFishPopulationService fishPopulationService;

    /**
     * 查询鱼群管理列表
     */
    @PreAuthorize("@ss.hasPermi('fish:population:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishPopulation fishPopulation)
    {
        startPage();
        List<FishPopulation> list = fishPopulationService.selectFishPopulationList(fishPopulation);
        return getDataTable(list);
    }

    /**
     * 导出鱼群管理列表
     */
    @PreAuthorize("@ss.hasPermi('fish:population:export')")
    @Log(title = "鱼群管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishPopulation fishPopulation)
    {
        List<FishPopulation> list = fishPopulationService.selectFishPopulationList(fishPopulation);
        ExcelUtil<FishPopulation> util = new ExcelUtil<FishPopulation>(FishPopulation.class);
        util.exportExcel(response, list, "鱼群管理数据");
    }

    /**
     * 获取鱼群管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('fish:population:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishPopulationService.selectFishPopulationById(id));
    }

    /**
     * 新增鱼群管理
     */
    @PreAuthorize("@ss.hasPermi('fish:population:add')")
    @Log(title = "鱼群管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishPopulation fishPopulation)
    {
        return toAjax(fishPopulationService.insertFishPopulation(fishPopulation));
    }

    /**
     * 修改鱼群管理
     */
    @PreAuthorize("@ss.hasPermi('fish:population:edit')")
    @Log(title = "鱼群管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishPopulation fishPopulation)
    {
        return toAjax(fishPopulationService.updateFishPopulation(fishPopulation));
    }

    /**
     * 删除鱼群管理
     */
    @PreAuthorize("@ss.hasPermi('fish:population:remove')")
    @Log(title = "鱼群管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishPopulationService.deleteFishPopulationByIds(ids));
    }
}
